//
//  AppDelegate.swift
//  VoiceRoom
//
//  Created by Rae on 2024/3/11.
//

import UIKit
@_exported import Stevia
@_exported import KakaJSON
@_exported import IQKeyboardManager

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        IQKeyboardManager.shared().isEnabled = true
        initializeWindow()
        return true
    }

    private func initializeWindow(){
        
//        self.window?.rootViewController = VRNavViewController(rootViewController: VRWelcomeViewController())
//        self.window?.rootViewController = VRTabBarViewController()
//        
//        self.window?.makeKeyAndVisible()
        
        if UserDefaults.standard.object(forKey: "UserInfo") != nil{
            let str = GetInfo(key: "UserInfo") as! NSDictionary
            let jsonData = InfoUtil.initInfo.deserialize(from: str)
            USEINFOMODEL = jsonData!
            let currentPage = UserDefaultsManager.getInt(forKey: .currentPage)
            if currentPage == 1{
                self.window?.rootViewController = VRNavViewController(rootViewController: VRUserInfoViewController())
            }else if currentPage == 2{
                self.window?.rootViewController = VRNavViewController(rootViewController: VRUserMoreInfoViewController())
            }else {
                self.window?.rootViewController = VRTabBarViewController()
            }
        }else{
            self.window?.rootViewController = VRNavViewController(rootViewController: VRWelcomeViewController())
        }
        
        self.window?.makeKeyAndVisible()
    }
}

